package com.app.TCES.controller;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.app.TCES.service.UploadService;

@Controller
public class UploadController {

	Logger log = LogManager.getLogger(UploadController.class);
	@Autowired
	UploadService uploadService;
	
	@ResponseBody
	@RequestMapping("/upload")
	public Map<String, Object> upLoad(@RequestParam("file")MultipartFile file,HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		Map<String, Object> map = new HashMap<String, Object>();
		
		try {
			String msg = uploadService.readExcel(file);
			
			map.put("msg", msg);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
		
	}
}
